--*************ANIMATION SUITE****************--
--**************Property of Hxrmn*****************--
--*************Hxrmn@comcast.net*****************--
--DO NOT RE-DISTRIBUTE WITHOUT HXRMN'S CONSENT--
--********************************************--

PANEL = {}


surface.CreateFont( "Tahoma", 20,  700, false, false, "TrackFont2" )


function PANEL:ColorBrightness(color,amt)
	local nc = Color(math.Clamp(color.r+amt,0,255)
			,math.Clamp(color.g+amt,0,255)
			,math.Clamp(color.b+amt,0,255)
			,color.a)
	return nc
end

function PANEL:Init()
	self:SetSize(0, 35)
	self.track = nil
	self.frames = {}
end

function PANEL:SetFrame(t,data)
	if(self.frames[t] == nil) then
		self.frames[t] = vgui.Create("vKeyFrame",self)
		self.frames[t]:SetTime(t)
	end
	self.frames[t].data = data
	self:PerformLayout()
end

function PANEL:ClearFrame(t)
	if(self.frames[t] == nil) then
		self.frames[t]:Remove()
		self.frames[t] = nil
	end
end

function PANEL:SetTrack(track)
	self.track = track
end

function PANEL:GetTrack()
	return self.track
end

function PANEL:DoClick()
	AS_GetAnimator():GetControls():ToggleTrack(self.track:GetId())
end

function PANEL:PerformLayout()
	for k,v in pairs(self.frames) do
		v:SetPos(80+(v:GetWide()*k),0)
		v:SetSize(v:GetWide(), self:GetTall())
	end
end

function PANEL:Paint()
	
	local text = "Track: " .. self.track:GetId()
	
	local color_text = Color( 255, 255, 255, 255 )
	local color_box  = Color( 120,120,120,255 )
		
		if(self.track:IsArmed()) then
			color_box  = Color( 255,120,120,255 )
		end
		
		surface.SetDrawColor(color_box.r,color_box.g,color_box.b,color_box.a)
		surface.DrawRect(0,0,self:GetWide(),self:GetTall())
		
		color_box = self:ColorBrightness(color_box,-20)
		
		surface.SetDrawColor(color_box.r,color_box.g,color_box.b,color_box.a)
		surface.DrawOutlinedRect(0,0,self:GetWide(),self:GetTall())
		
		draw.DrawText( text, "TrackFont2", 4, 8, color_text, TEXT_ALIGN_LEFT )

	return true
		
end


vgui.Register("vTrack", PANEL, "Button")